package com.umfb.timertask.spider;

/*
 * 测试类
 */
public class Test {
	int page = 1;

	public static void main(String[] args) {
		Test test = new Test();
		test.test();

	}

	public String getDataByPage(int page) {
		Product product = new Product("2017-09-14", "=2017-11-12", "", "34", String.valueOf(page), "13075",
				"20413");
		Spider spider = new Spider();
		String result = spider.crawling(product);
		return result;
	}

	public void test() {
		new Thread(new Runnable() {
			@Override
			public void run() {
				getData();
			}

			private String getData() {
				page++;
				String result = getDataByPage(page);
				if (!result.endsWith("最后一页")) {
					System.out.println("第" + page + "页" + result);
					try {
						Thread.sleep(100);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					getData();

				} else {
					System.out.println("第" + page + "页" + result);
				}

				return result;
			}

		}).start();
	}

}